package com.wxb.api.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wxb.api.common.ErrorCode;
import com.wxb.api.exception.BusinessException;
import com.wxb.api.service.InterfaceInfoService;
import com.wxb.api.mapper.InterfaceInfoMapper;
import com.wxb.common.model.entity.InterfaceInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
* @author 12796
* @description 针对表【interface_info(接口信息)】的数据库操作Service实现
* @createDate 2023-08-02 17:46:27
*/
@Service
public class InterfaceInfoServiceImpl extends ServiceImpl<InterfaceInfoMapper, InterfaceInfo>
    implements InterfaceInfoService{

    @Override
    public void validInterfaceInfo(InterfaceInfo interfaceInfo, boolean add) {
        if (interfaceInfo == null) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        String iFName = interfaceInfo.getIFName();
        if (add){
            if(StringUtils.isAnyBlank(iFName)){
                throw new BusinessException(ErrorCode.PARAMS_ERROR);
            }
        }
        if (StringUtils.isNotBlank(iFName) && iFName.length() > 20){
            throw new BusinessException(ErrorCode.PARAMS_ERROR,"名字过长");
        }
    }
}






